package com.share.html;

import java.lang.management.ManagementFactory;

import javax.management.MBeanServer;
import javax.management.ObjectName;

import com.share.Mbean.Hello;
import com.sun.jdmk.comm.HtmlAdaptorServer;

public class HelloAgent {

	public static void main(String[] args) throws Exception {
		//jconsole 访问方式
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		ObjectName helloName = new ObjectName("sunxj-jmx:name=hello");
		server.registerMBean(new Hello(), helloName);

		
		//用html方式访问
		ObjectName htmlName = new ObjectName("sunxj-jmx:name=htmlAdapter,prot=8082");
		HtmlAdaptorServer adapter = new HtmlAdaptorServer();
		server.registerMBean(adapter, htmlName);
		adapter.start();
		System.out.println("html 访问方式：HelloAgent start...");
	}
}
